package com.h6.crm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.h6.crm.annotation.ResponseResult;
import com.h6.crm.service.QuoteService;
import com.h6.crm.util.pojo.R;
import com.h6.crm.util.pojo.dto.QuoteDetailDto;
import com.h6.crm.util.pojo.vo.QueryQuoteReocrdVO;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;

import com.h6.crm.entity.QuoteRecord;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "报价管理", description = "报价管理的API")
@RestController
@RequestMapping("/quote")
@ResponseResult
public class QuoteController {

  @Autowired
  QuoteService quoteService;

  @Operation(summary = "分页查询全部报价")
  @ApiResponses({
      @ApiResponse(responseCode = "200", content = {
          @Content(schema = @Schema(implementation = R.class), mediaType = "application/json") }) })
  @PostMapping("/list")
  public Page<QuoteRecord> queryQuoteReocrdList(@Valid @RequestBody QueryQuoteReocrdVO recordVo) {
    return quoteService.queryQuoteReocrdList(recordVo);
  }

  @Operation(summary = "根据ID查询报价详细信息")
  @ApiResponses({
      @ApiResponse(responseCode = "200", content = {
          @Content(schema = @Schema(implementation = R.class), mediaType = "application/json") }) })
  @PostMapping("/{quoteId}")
  public QuoteDetailDto getQuoteRecordDetail(
      @Parameter(description = "报价记录ID", required = true) @PathVariable("quoteId") Long quoteId) {
    return quoteService.getQuoteRecordDetailById2(quoteId);
  }

}
